import {
	ref,
	reactive,
	computed
} from 'vue'
import {
	defineStore
} from "pinia"

export const useStore = defineStore('store', () => {
	const tabber = ref([]);
	const role = ref(wx.getStorageSync('role')?wx.getStorageSync('role'):'passenger');
	const destination = ref('');
	const startLatLng = ref('');
	const getTabBarList = computed(() => {})
	const getDestination = computed(() => {

	});
	const getRole = () => {
		let tabbarList = require('../static/tabbarList/index.js').default
		console.log(tabbarList)
		console.log()
		return tabbarList[role.value]
	}
	
	const changeRole = (val) => {
		return new Promise((resolve,reject)=>{
			role.value=val
			wx.setStorageSync('role',val)
			resolve()
		})
		
	}

	const setDestination = (param) => {
		destination.value = {
			latitude: param.lat,
			longitude: param.lng
		};
	}

	const setStartLatLng = (param) => {
		startLatLng.value = param;
	}

	const reset = () => {
		destination.value = "";
	}


	return {
		startLatLng,
		setStartLatLng,
		getRole,
		changeRole,
		destination,
		getTabBarList,
		setDestination,
		role,
		reset
	}
})